﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace BAL.EstRec.CAT
{
    public class Pos
    {
        public string id_Pos;
        public string dsc_pos;
        public static DataTable GetDataNamePos(string nombrePos)
        {
            try
            {
                DataTable dt = DAL.EstRec.SrvDB.ExecuteQuery("EXEC SP_ER_v050_GET_POS '" + nombrePos + "'");
                if (dt.Rows.Count==0)
                {
                    return null;
                }
                else
                {
                    return dt;        
                }
            }
            catch (Exception)
            {
                
                throw;
            }
        }
        public static List<Pos> GetDataPos()
        {
            try
            {
                DataTable dt = DAL.EstRec.SrvDB.ExecuteQuery("EXEC SP_ER_v050_GET_POS");
                if (dt.Rows.Count == 0)
                {
                    return null;
                }
                else
                {
                    List<Pos> list = dt.AsEnumerable().Select(
                        row => new Pos
                        {
                            id_Pos = String.IsNullOrEmpty(row.Field<string>("ID_POS"))
                            ? ""
                            : row.Field<string>("ID_POS"),
                            dsc_pos = String.IsNullOrEmpty(row.Field<string>("POS"))
                            ? ""
                            : row.Field<string>("POS"),
                        }
                        ).ToList();
                    return list;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public Pos()
        { 
        }
        public Pos(string id_Pos, string dsc_pos)
        {
            this.id_Pos = id_Pos;
            this.dsc_pos = dsc_pos;
        }
    }

}
